   import com.rattkin.event.ConfigEvent;
   import com.rattkin.event.RemoteErrorEvent;
   import com.rattkin.event.StateEvent;
   import com.rattkin.event.StatsEvent;
   import com.rattkin.model.vo.EventVO;
   import com.rattkin.model.vo.FlagVO;
   import com.rattkin.model.vo.GameStatsVO;
   import com.rattkin.model.vo.GameVO;
   import com.rattkin.model.vo.KillratioStatsVO;
   import com.rattkin.model.vo.PlayerStatsVO;
   import com.rattkin.model.vo.PlayerVO;
   import com.rattkin.model.vo.TotalGameStatsVO;
   
   import mx.controls.Alert;
   import mx.formatters.DateFormatter;
   import mx.events.FlexEvent;
   import mx.messaging.ChannelSet;

   [Bindable] public var applicationState:String;
   [Bindable] public var amfChannelSet:ChannelSet;   

   // fake definitions, just to trigger mapping for RemoteObject
   private var references:Array = [FlagVO, EventVO, GameStatsVO, GameVO, PlayerStatsVO, PlayerVO, TotalGameStatsVO, KillratioStatsVO ];   
      
   public function applicationInit(event:FlexEvent):void {
		loadConfig();
   }      
   
   public function loadConfig():void {
		dispatchEvent(new ConfigEvent(ConfigEvent.LOAD));
   }  
      
   public function configLoaded(event:ConfigEvent):void {
		loadStats();
   }  
   
   public function loadStats():void {
   		dispatchEvent(new StateEvent(StateEvent.CHANGE, StateEvent.STATE_LOAD));   		
		dispatchEvent(new StatsEvent(StatsEvent.LOAD));
   }     
       
   public function statsLoaded(event:StatsEvent):void {
   		dispatchEvent(new StateEvent(StateEvent.CHANGE, StateEvent.STATE_MAIN));      		
   }     
      
   public function showError(event:RemoteErrorEvent):void {
	    Alert.show(event.message, "Error");
   }  
   
/*
   public function killratioLoaded(event:KillratioEvent):void {
   	progress.visible = false;
   	
   	var index:int = 0;
   	for (var player:Object in killratio.players){
   		var ls:LineSeries = new LineSeries();
   		var s:SolidColorStroke = new SolidColorStroke();
   		s.weight = 2;
   		
   		var color:uint;

	   		
		   switch (player as String)  
		   {  
		      case 'rat[tkin]':  
		        color = 0x0000FF;  
		        break;  
		      case 'al':  
		        color = 0xFF0000;  
		        break;  
		      case 'piochoo':  
		        color = 0x00FF00;  
		        break;  
		      case 'jan the man':  
		        color = 0xFFFF00;  
		        break;
		      case 'Rafoo':  
		        color = 0x00FFFF;  
		        break;  		
		      default:  
		        color = 0x000000;  
		        break;  
		   }     		
   		
   		s.color = color;    
        ls.displayName = player as String;    
        ls.dataProvider = killratio.players[player];
        // ls.setStyle('lineStroke', s); 
   		
	    var series:Array = lineChart.series;   
	    series.push(ls);  
	    lineChart.series = series;   
	    lineChart.invalidateSeriesStyles(); 
    	index++;
	}
	
	lineChart.visible = true;
   	
   }   
   
   public function statsLoaded(event:StatsEvent):void {
   	progress.visible = false;
   	
   	var flattenedArray:Array = new Array();
   	
	for each (var entry:PlayerStatsVO in stats.players) {
		var obj:Object = new Object();
	    obj.name = entry.name;
	    obj.kills = entry.kills;
	    obj.deaths = entry.deaths;
	    obj.suicides = entry.suicides;
	    obj.killratio = entry.killratio;
	    obj.score = entry.score;
	    obj.power = entry.power;	    
	    flattenedArray.push(obj);
	}   	
   	
    myGrid.dataProvider = flattenedArray;
    myGrid.visible = true;
   }       
   */     
   
   
